<template>
    <div id="body">
         <div class="login-box">
        <h1>登录</h1>
        <div class="input-box">
            <div class="input-text">
                <span class='iconfont icon-mine'></span>
                <input type="text" placeholder="用户名" v-model="user.userUsername">
            </div>
            <div class="input-text">
                <span class='iconfont icon-lock'></span>
                <input type="password" placeholder="密码" v-model="user.userPassword">
            </div>
            <div class="input-btn" @click="login">
                登录
            </div>
            <div  class="input-text reg">
                还没账户？<router-link to="/register">立即注册</router-link>
            </div>
        </div>
    </div>
    </div>
</template>

<script>
// import '@/assets/css/login/iconfont.css'
// import '@/assets/css/login/login.css'
import API from "@/api/request";
export default {
    name: 'BookShopLogin',

    components: {  },

    directives: {  },

    data() {
        return {
            user:{},
        };
    },

    mounted() {
        
    },

    methods: {
         login() {
      if (!this.user.userUsername) {
        this.$message({
          type: "warning",
          message: "请输入用户名"
        })
        return;
      }
      if (!this.user.userPassword) {
        this.$message({
          type: "warning",
          message: "请输入密码"
        })
        return;
      }

      API.post("/api/msslyyUser/login", this.user).then(res => {
        if (res.code === '0') {
          this.$message({
            type: "success",
            message: "登录成功"
          })
          sessionStorage.setItem("user1", JSON.stringify(res.data))
         API.get("/api/statistics/"+ res.data.id)
          this.$router.replace("/")
        } else {
          this.$message({
            type: "error",
            message: res.msg
          })
        }
      })
    }
        
    },
};
</script>

<style scoped>
.login-box .input-box .input-text span[data-v-10d9df09]{
    margin-top: 35px;
}
.reg{
    margin-top: 20px;
    color: white
}
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

#body {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    background-image: url("../assets/images/login/1.jpg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    overflow: hidden;
}

.login-box {
    display: flex;
    justify-content: center;
    align-content: space-around;
    flex-wrap: wrap;
    width: 600px;
    height: 400px;
    background-color: rgba(0, 0, 0, .5);
    border: 10px;
    padding: 20px 50px;
    border-radius: 20px;
}

.login-box h1 {
    width: 100%;
    display: flex;
    justify-content: center;
    color: #fff;
    font-size: 30px;
}

.login-box .input-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    transform: translateY(-35px);
}

.login-box .input-box .input-text {
    width: 100%;
    display: flex;
    justify-content: center;
}

.login-box .input-box .input-text span {
    color: white;
    font-size: 18px;
    margin-top: 20px;
}

.login-box .input-box .input-text input {
    border: 0;
    padding: 6px;
    border-bottom: 1px solid white;
    background-color: #ffffff00;
    color: #fff;
    margin-top: 20px;
}

.login-box .input-box .input-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 25px;
    width: 145px;
    height: 50px;
    color: #fff;
    background: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%);
    border-radius: 25px;
    cursor: pointer;
}

.login-box .input-box .sign-up {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 40px;
    color: white;
    font-size: 15px;
    pointer-events: none;
}

.login-box .input-box .sign-up a {
    color: #3498db;
    text-decoration: none;
    cursor: pointer;
}
</style>